package com.heima.wemedia.controller.v1;


import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.IWmMaterialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * <p>
 * 自媒体图文素材信息表 前端控制器
 * </p>
 *
 * @author chana
 * @since 2024-08-15
 */
@RestController
@RequestMapping("/api/v1//material")
@Api("自媒体图文素材")
public class WmMaterialController {

    @Resource
    IWmMaterialService iWmMaterialService;

    @PostMapping("/upload_picture")
    @ApiOperation("图文素材上传")
    public ResponseResult uploadPicture(MultipartFile multipartFile){
        return iWmMaterialService.uploadPicture(multipartFile);
    }

    @PostMapping("list")
    @ApiOperation("分页查询")
    public ResponseResult pageList(@RequestBody WmMaterialDto dto){
        return iWmMaterialService.pageList(dto);
    }

    @GetMapping("/collect/{id}")
    @ApiOperation("根据id修该收藏")
    public ResponseResult updateCollect(@PathVariable Integer id){
        return iWmMaterialService.updateCollect(id);
    }

    @GetMapping("/del_picture/{id}")
    @ApiOperation("删除素材")
    public ResponseResult delPictureById(@PathVariable Integer id){
        return iWmMaterialService.delPictureById(id);
    }

}
